﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;

namespace TVGrid.ViewModel
{
    //Used for toggeling login | logout frame
    [ValueConversion(typeof(Visibility), typeof(Visibility))]
    class VisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (parameter is string)
            {
                string prm = (string)parameter;
                Visibility _value = (Visibility)value;
                if (prm == "logout")
                {
                    switch (_value)
                    {
                        case Visibility.Collapsed:
                            _value = Visibility.Visible;
                            break;
                        case Visibility.Hidden:
                            _value = Visibility.Visible;
                            break;
                        case Visibility.Visible:
                            _value = Visibility.Collapsed;
                            break;
                        default:
                            break;
                    }

                    return _value;
                }
                else
                    return value;
            }
            else
                return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }
}
